package com.example.servicechat.controller;



import com.example.entity.enums.ResponseCodeEnum;
import com.example.entity.vo.ResponseVO;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class ABaseController {
    protected static final String STATUC_SUCCESS = "success";

    protected static final String STATUC_ERROR = "error";

    protected <T> ResponseVO getSuccessResponseVO(T t) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setStatus(STATUC_SUCCESS);
        responseVO.setCode(ResponseCodeEnum.CODE_200.getCode());
        responseVO.setInfo(ResponseCodeEnum.CODE_200.getMsg());
        responseVO.setData(t);
        return responseVO;
    }

    protected <T> ResponseVO getBusinessErrorResponseVO(T t) {
        ResponseVO vo = new ResponseVO();
        vo.setStatus(STATUC_ERROR);
        vo.setCode(ResponseCodeEnum.CODE_500.getCode());
        vo.setInfo(ResponseCodeEnum.CODE_500.getMsg());
        vo.setData(t);
        return vo;
    }

//    protected <T> ResponseVO getServerErrorResponseVO(T t) {
//        ResponseVO vo = new ResponseVO();
//        vo.setStatus(STATUC_ERROR);
//        vo.setCode(ResponseCodeEnum.CODE_500.getCode());
//        vo.setInfo(ResponseCodeEnum.CODE_500.getMsg());
//        vo.setData(t);
//        return vo;
//    }
//    protected TokenUserInfoDto getTokenUserInfo(String token) {
//        TokenUserInfoDto tokenUserInfoDto = new TokenUserInfoDto();
//
//        return tokenUserInfoDto;
//    }
//
//    public static void main(String[] args) {
//        RedisUtil redisUtil = new RedisUtil();
//        TokenUserInfoDto  tokenUserInfoDto = (TokenUserInfoDto)
//                redisUtil.get(Constants.REDIS_KEY_WS_TOKEN + "d3441fbe515a297e6d94642ecbff0ded");
//        System.out.println(tokenUserInfoDto);
//    }
}
